/**
* Copyright © 2018 深圳市巨鼎医疗设备有限公司
*/
package com.zl.websocket.controller;

import java.util.Map;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zl.websocket.entity.dto.ChatMessageDto;
import com.zl.websocket.service.MessageService;

/**
 * websocoket controller
 * 
 * @author Zhouych
 * @date 2018年9月4日 下午6:59:39
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/websocket")
public class WebsocketController {

	private MessageService websocketMessageService;

	/**
	 * 接收到客户端消息
	 * 
	 * @param message
	 */
	@MessageMapping("/chat")
	public void chat(ChatMessageDto message) {
		websocketMessageService.send(message.getToUserIds(), message.getPayload());
	}
	
	/**
	 * 广播消息
	 * @param message
	 * @return
	 */
	@PostMapping("/broadcast")
	public String broadcast(Map<String, Object> message) {
		
		return null;
	}
}
